package admin_api

import (
	"github.com/gin-gonic/gin"
	"shop/admin/admin_service"
	"shop/utils/convertutil"
	"shop/utils/sessionutil"
)

func GetUserList(c *gin.Context) {
	pageNo := convertutil.ParseInt(c.DefaultQuery("pageNo", "1"))
	pageSize := convertutil.ParseInt(c.DefaultQuery("pageSize", "10"))
	c.JSON(200, admin_service.GetUserList(sessionutil.GetShopIdFromCtx(c), pageNo, pageSize))
}

func UpdateUserStatus(c *gin.Context) {
	userId := convertutil.ParseInt64(c.Param("userId"))
	newStatus := convertutil.ParseInt(c.Param("newStatus"))
	c.JSON(200, admin_service.UpdateUserStatus(userId, sessionutil.GetShopIdFromCtx(c), newStatus))
}
